// 管理员相关类型定义

import type { User } from './user'
import type { Post } from './forum'
import type { Question } from './question'
import type { LearningGroup as StudyGroup } from './group'
import type { LearningResource as Resource } from './resource'

export interface AdminStats {
  totalUsers: number
  activeUsers: number
  newUsersToday: number
  newUsersThisWeek: number
  totalPosts: number
  newPostsToday: number
  pendingPosts: number
  totalQuestions: number
  newQuestionsToday: number
  totalGroups: number
  activeGroups: number
  totalResources: number
  downloadedResources: number
  userGrowth: {
    date: string
    count: number
  }[]
  postActivity: {
    date: string
    count: number
  }[]
  resourceDownloads: {
    date: string
    count: number
  }[]
  topCategories: {
    id: number
    name: string
    count: number
  }[]
}

export interface AdminDashboardData {
  stats: AdminStats
  recentUsers: User[]
  recentPosts: Post[]
  recentQuestions: Question[]
  recentGroups: StudyGroup[]
  recentResources: Resource[]
  pendingItems: {
    posts: number
    comments: number
    resources: number
    groupApplications: number
  }
  systemStatus: {
    uptime: string
    memoryUsage: string
    cpuUsage: string
    databaseConnections: number
    apiRequests: {
      total: number
      today: number
      errorRate: string
    }
  }
}

export interface AdminActionLog {
  id: number
  adminId: number
  adminName: string
  actionType: 'USER_BAN' | 'USER_UNBAN' | 'POST_DELETE' | 'POST_APPROVE' | 'QUESTION_DELETE' | 'GROUP_DELETE' | 'RESOURCE_DELETE' | 'SYSTEM_CONFIG'
  targetType: 'USER' | 'POST' | 'QUESTION' | 'GROUP' | 'RESOURCE' | 'SYSTEM'
  targetId?: number
  targetName?: string
  details?: Record<string, any>
  actionTime: string
  ipAddress: string
}

export interface AdminSettings {
  siteName: string
  siteDescription: string
  logoUrl: string
  faviconUrl: string
  footerText: string
  enableRegistration: boolean
  requireEmailVerification: boolean
  postApprovalRequired: boolean
  resourceApprovalRequired: boolean
  defaultUserRole: 'USER' | 'GUEST'
  maxPostsPerDay: number
  maxResourcesPerDay: number
  cacheEnabled: boolean
  cacheTTL: number
}

export interface SystemNotification {
  id: number
  title: string
  content: string
  type: 'INFO' | 'WARNING' | 'ERROR' | 'SUCCESS'
  target: 'ALL' | 'USERS' | 'ADMINS'
  isActive: boolean
  startTime?: string
  endTime?: string
  createdAt: string
  createdBy?: number
}

// 导入其他必要的类型
export type { User } from './user'
export type { Post } from './forum'
export type { Question } from './question'
export type { LearningGroup as StudyGroup } from './group'
export type { LearningResource as Resource } from './resource'